package com.zmm.common.base.model;

import java.io.Serializable;
import java.util.List;

/**
 * 查询参数封装类
 * @author 900045
 * @description:
 * @name Query
 * @date By 2021-06-28 16:01:26
 */
public class Query<T> implements Serializable {
	
	private static final long serialVersionUID = -8769104813618010919L;


	/**
	 * 是否分页
	 */
	private boolean doPage = true;

	/**
	 *  分页信息
	 */
	private Paging paging;

	/**
	 * 查询条件
	 */
	private Object condition;
	/**
	 * 查询结果
	 */
	private List<T> results;

	/**
	 *  扩展结果对象
	 */
	private Object extResult;

	private String orderBy;

	private String extData;

	public Query() {
		this.paging = new Paging();
	}

	public Query(Paging paging) {
		this.paging = paging;
	}
	

	/**
	 * 取消分页
	 */
	public void cancelPage() {
		this.doPage = false;
		this.paging = null;
	}

	/**
	 *  设置记录数
	 *
	 * @param total
	 */
	public void setTotal(Integer total) {
		if (doPage && paging != null) {
			paging.setTotalNumber(total);
		}
	}

	/**
	 *  设置记录数
	 * @param currentPage
	 */
	public void setCurrentPage(Integer currentPage) {
		if (doPage && paging != null) {
			paging.setCurrentPage(currentPage);
		}
	}

	public boolean isDoPage() {
		return doPage;
	}

	public void setDoPage(boolean doPage) {
		this.doPage = doPage;
	}

	public Paging getPaging() {
		return paging;
	}

	public void setPaging(Paging paging) {
		this.paging = paging;
	}

	public Object getCondition() {
		return condition;
	}

	public void setCondition(Object condition) {
		this.condition = condition;
	}

	public List<T> getResults() {
		return results;
	}

	public void setResults(List<T> results) {
		this.results = results;
	}

	public Object getExtResult() {
		return extResult;
	}

	public void setExtResult(Object extResult) {
		this.extResult = extResult;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public String getExtData() {
		return extData;
	}

	public void setExtData(String extData) {
		this.extData = extData;
	}
}
